import Vuex from 'vuex'
import Vue from 'vue'
Vue.use(Vuex)


// const iac2 = uni.createInnerAudioContext()
const store = new Vuex.Store({
	state: {
		song:{// 用来存储当前播放的歌曲
			id: 1474342935,
			image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
			url: "http://m7.music.126.net/20240225203123/27fb7c388fa9c311c1614f5f7d09cb3c/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3788382918/563e/db38/daf2/02b23c07e1a6f94f38cdbb01cad7afcb.mp3",
			// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
			playState: false,
			author: '黑猫警长Giao',
			title: '画画的baby',
			lyric: ''
		},
		nextPlay: {
			// 列表循环/单曲循环?
			flag: true,
			// 已经存入列表的数据
			list: []
		}
		
	},
	mutations: {
		songChange(state, provider){
			state.song.id= provider.id
			state.song.image = provider.image || 'https://img.zcool.cn/community/01deed576019060000018c1bd2352d.gif'
			state.song.url = provider.url
			state.song.playState = provider.playState
			state.song.author = provider.author || '未知'
			state.song.title = provider.title || '未知'
		},
		// 可添加/删除/修改列表
		nextPlayListChange(state,provider){
			if('list' in provider)state.nextPlay = {...provider}
			else{
				state.nextPlay.list.push(provider)
			}
		},
		nextPlayShift(state){
			if(state.nextPlay.list){
				console.log(state.nextPlay.list)
				state.nextPlay.list.shift()
				console.log(state.nextPlay.list)
			}
			
		}
	},
	getters: {
		songData: state=>{
			return state.song
		},
		nextPlayData: state=>{return state.nextPlay}
	}
})
export default store